package com.test.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.test.test.dto.common.ResultResp;
import com.test.test.dto.userModule.UserParam;
import com.test.test.dto.userModule.UserResp;
import com.test.test.service.UserService;

@RestController
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	UserService userService;
	
	@PostMapping("/save")
	@CachePut
	public Integer save(@RequestBody UserParam param) throws Exception{
		ExpressionParser parser = new SpelExpressionParser();
		return 1;
	}
	
	@GetMapping("/info/{userId}")
	@Cacheable(cacheNames="xx",key="",condition="",unless="")
	public 	ResultResp<UserResp> save(@PathVariable("userId") Integer userId) throws Exception{
		return userService.findById(userId);
	}
	@GetMapping("/test")
	public 	ResultResp<Boolean> test( ) throws Exception{
		return userService.tetsRollBack();
	}
}
